/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package beans.forms;

import beans.LoginBean;
import datamodel.Post;
import datamodel.Ticket;
import ejb.PostManager;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;

/**
 *
 * @author Administrator
 */
@ManagedBean
@RequestScoped
public class NewPostForm {

    private String content;
    private Ticket ticket;
    @EJB
    private PostManager pm;
    @ManagedProperty(value = "#{login}")
    private LoginBean login;

    public void savePost(Ticket t) {
        pm.savePost(new Post(content, login.getLoggedUser(), t));
        content = null;
    }

    /**
     * @param login the login to set
     */
    public void setLogin(LoginBean login) {
        this.login = login;
    }

    /**
     * @return the content
     */
    public String getContent() {
        return content;
    }

    /**
     * @param content the content to set
     */
    public void setContent(String content) {
        this.content = content;
    }

    /**
     * @return the ticket
     */
    public Ticket getTicket() {
        return ticket;
    }

    /**
     * @param ticket the ticket to set
     */
    public void setTicket(Ticket ticket) {
        this.ticket = ticket;
    }
}
